package com.coolbi.security.dao.impl;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.security.dao.RoleToUrlDao;
import com.coolbi.security.entity.RoleToUrl;
import com.coolbi.security.entity.RoleUrl;
import com.coolbi.security.entity.Roles;
import com.coolbi.security.mapper.RoleToUrlMapper;

public class RoleToUrlDaoImpl implements RoleToUrlDao {

	@Autowired
	private RoleToUrlMapper roleToUrlMapper;
	public void setRoleToUrlMapper(RoleToUrlMapper roleToUrlMapper) {
		this.roleToUrlMapper = roleToUrlMapper;
	}
	
	@Override
	public List<RoleToUrl> find(Map<String, Object> parameter) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToUrl> find(Map<String, Object> parameter, int offset,
			int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int count(Map<String, Object> parameter) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<RoleToUrl> search(String keyword, int offset, int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int countByKeyword(String keyword) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public RoleToUrl save(RoleToUrl obj) {
		roleToUrlMapper.save(obj);
		return obj;
	}

	@Override
	public int update(RoleToUrl obj) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delete(long id) {
		return roleToUrlMapper.delete(id);
	}

	@Override
	public RoleToUrl get(long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToUrl> list() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleToUrl> list(int offset, int limit) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int count() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Roles> findRoleByUrlId(long id) {
		return roleToUrlMapper.findRoleByUrlId(id);
	}

	@Override
	public List<RoleUrl> findUrlByRoleId(long id) {
		return roleToUrlMapper.findUrlByRoleId(id);
	}

	@Override
	public int deleteByUrlId(long id) {
		return roleToUrlMapper.deleteByUrlId(id);
	}

	@Override
	public List<Long> findByUrlsAndRoleId(Long[] urlArray, Long roleId) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("roleId", roleId);
		parameter.put("urlId", Arrays.asList(urlArray));
		return roleToUrlMapper.findByUrlsAndRoleId(parameter);
	}

	@Override
	public int deleteByUrlIds(Long[] urlArray, Long roleId) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("roleId", roleId);
		parameter.put("urlId", Arrays.asList(urlArray));
		return roleToUrlMapper.deleteByUrlIds(parameter);
	}

}
